<template>
	<view class="container">
		<!-- <view class="shop_box">
			<view class="commodity_box">
				<div class="list" v-for="item in goodsList" :key="item" @click="godetails(item)">
					<image :src="item.image" mode=""></image>
					<view class="text_box">
						<view class="name">{{item.store_name}}</view>
						<view class="remake">{{item.store_name}}</view>
						<view class="renzhen">{{item.price}}</view>
					</view>
				</div>
			</view>
		</view> -->
		<view class="commodity_box">
			<view class="list" v-for="item in goodsList" :key="item" @click="godetails(item)">
				<image :src="item.image" mode=""></image>
				<view class="text_box">
					<view class="name">{{item.store_name}}</view>
					<!-- <view class="remake">2222</view> -->
					<view class="price_text">
						<text class="big"><text>￥</text>{{item.price}}</text>
						<text class="small" v-if="item.ot_price"><text>￥</text>{{item.ot_price}}</text>
					</view>
					<view class="btn_boxs" v-if="isLogin">
						<view></view>
						<view class="addcart" @click.stop="goodsClick(item)">
							选规格
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-loadmore :status="status" v-if="status !== 'nomore'" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				goodsList: [],
				page: 1,
				pageSize: 10,
				total: 1,
				count: 1,
				typeId: 0,
				status: 'loadmore'
			}
		},
		onLoad(opdata) {
			this.typeId = opdata.id
			uni.setNavigationBarTitle({
				title: opdata.title // 需要设置的标题文本
			});
			this.getGoodsList()
		},
		onReachBottom() {
			if (this.page >= this.count) return this.status = 'nomore';
			this.status = 'loading';
			this.page = ++this.page;
			this.getGoodsList()
		},
		methods: {
			async getGoodsList() {
				await this.$allApi.getHotList({
					page: this.page,
					limit: this.pageSize
				}).then(res => {
					if (res.data.length < this.pageSize) {
						this.status = 'nomore'
					} else {
						this.status = 'loadmore'
					}
					this.goodsList = [...res.data, ...this.goodsList]
				})
			},
			godetails(item) {
				this.$gourl('/mallPage/goodsDetails?id=' + item.id)
			},
		}
	}
</script>

<style lang="scss" scoped>
	.commodity_box {
		padding: 30rpx 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-wrap: wrap;

		.list {
			width: 340rpx;
			border-radius: 20rpx;
			padding: 20rpx;
			background: #FFFFFF;
			overflow: hidden;
			margin-bottom: 20rpx;

			.text_box {
				padding: 12rpx 0;
				position: relative;
				line-height: 2;
				padding-bottom: 0;

				.price_text {
					display: flex;
					align-items: center;
					justify-content: flex-start;

					.big {
						font-size: 40rpx;
						color: #EA3D37;

						text {
							font-size: 24rpx;
						}
					}

					.small {
						font-size: 24rpx;
						color: #999999;
						text-decoration: line-through;

						text {
							font-size: 16rpx;
						}
					}
				}

				.btn_boxs {
					display: flex;
					align-items: center;
					justify-content: space-between;
				}

				.addcart {
					width: 80rpx;
					height: 44rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					color: #fff;
					font-size: 20rpx;
					background: #EA3D37;
					border-radius: 6rpx;

				}

				.name {
					font-size: 28rpx;
					width: 300rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
				}

				.remake {
					font-size: 24rpx;
					color: #999;
				}

				.renzhen {
					font-size: 28rpx;
					color: #EA3D37;
				}
			}

			image {
				width: 300rpx;
				height: 248rpx;
				border-radius: 20rpx, 20rpx, 0rpx, 0rpx;

			}
		}
	}

	.shop_box {
		margin-top: 30rpx;

		.commodity_box {
			padding: 30rpx 20rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			flex-wrap: wrap;

			.list {
				width: 340rpx;
				border-radius: 20rpx;
				padding-bottom: 20rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 4rpx 7rpx 1rpx rgba(0, 96, 255, 0.14);
				overflow: hidden;
				margin-bottom: 20rpx;

				.text_box {
					padding: 12rpx 10rpx;
					position: relative;
					line-height: 2;

					.quan {
						width: 76rpx;
						margin-top: 20rpx;
						height: 28rpx;
						border-radius: 6rpx;
						background: #EF1300;
						color: #fff;
						display: flex;
						align-items: center;
						justify-content: center;
						font-size: 16rpx;

					}

					.addcart {
						position: absolute;
						right: 20rpx;
						bottom: 16rpx;
						width: 50rpx;
						height: 50rpx;
						border-radius: 50%;
						display: flex;
						align-items: center;
						justify-content: center;
						color: #fff;
						font-size: 24rpx;
						background: #EA3D37;

					}

					.name {
						font-size: 28rpx;
					}

					.remake {
						font-size: 24rpx;
						color: #999;
					}

					.renzhen {
						font-size: 24rpx;
						color: #EA3D37;
					}
				}

				image {
					width: 340rpx;
					height: 248rpx;
					border-radius: 20rpx, 20rpx, 0rpx, 0rpx;

				}
			}
		}
	}

	.container {
		padding-top: 30rpx;
		min-height: 100vh;
		background: #f8f8f8;
	}

	.search_box {
		width: 710rpx;
		margin: 0 auto;
		height: 60rpx;
		border-radius: 30rpx;
		background: #FFFFFF;
		border: 2rpx solid #EA3D37;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding-left: 28rpx;
		padding-right: 4rpx;

		input {
			flex: 1;
			padding: 0 20rpx;
		}

		.search_button {
			width: 110rpx;
			height: 48rpx;
			border-radius: 24rpx;
			background: linear-gradient(90deg, #8EC300 0%, #EA3D37 100%);
			display: flex;
			align-items: center;
			justify-content: center;
			color: #fff;
			font-size: 24rpx;
		}
	}
</style>